<template>
<div class="modal" tabindex="-1" role="dialog" aria-hidden="true" :id="id">
  <div class="modal-dialog modal-xl">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">
          <slot name="title">
            查看图片
          </slot>
        </h5>
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
      </div>
      <div class="modal-body">
        <img :src="imgUrl" class="img-fluid" />
      </div>
    </div>
  </div>
</div>
</template>

<script>
  import $ from 'jquery'

export default {
  props: {
    id: {
      type: String,
      default: "viewerModal"
    }
  },
  data () {
    return {
      imgUrl: ''
    }
  },
  methods: {
    modal: function (imgUrl) {
      this.imgUrl = imgUrl
      $(this.$el).modal()

      this.promise = new Promise((resolve, reject) => {
        this.resolve = resolve
        this.reject = reject
      })
      return this.promise
    },
  }
}
</script>
